<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<form:form commandName="model" cssClass="validate"
	action="app/user/savePortalUserInfo">
	<form:hidden path="id" />
    
	<div class="header">
		<h2>&nbsp;&nbsp;基本信息</h2>
	</div>

	<table class=" form-table">
		<tbody>
			<tr>
				<c:if test="${not empty model.id }">
					<td class="td2" rowspan="7"
						style="text-align: center;width:155px !important;vertical-align: top;">


						<isperp:photoUploader imgName="photo" cutType="1" imgWidth="105"
							imgHeight="110" imgSrc="${model.photo}" id="photo"
							imgPath="users/${model.name }" imgFormat="png/gif/jpg"
							showDescription="false"></isperp:photoUploader>
					</td>
				</c:if>
				<td class="td1">账号：</td>
				<td class="td2"><c:choose>
						<c:when test="${empty model.name }">
							<form:input path="name" onchange="userNameChange()" />
							<form:hidden path="password" />
						</c:when>
						<c:otherwise>
							<form:hidden path="name" />
							<label style="font-weight: 700;padding:0 2px;color:#000000">${model.name}</label>
						</c:otherwise>
					</c:choose>
				</td>



			</tr>


			<tr>
				<td class="td1">姓名：</td>
				<td class="td2"><form:input path="fullname" cssClass="required" />
				</td>


			</tr>

			<tr>


				<td class="td1">手机：</td>
				<td class="td2"><form:input path="mobile" cssClass=""
						cssStyle="width:80%" maxlength="100" />
				</td>

			</tr>
			<tr>
				<td class="td1">邮件：</td>
				<td class="td2"><form:input path="email" cssClass=" email"
						maxlength="100" cssStyle="width:80%" />
				</td>
			</tr>
			<tr>
				<td class="td1">电话：</td>
				<td class="td2"><form:input path="tel" maxlength="100"
						cssStyle="width:80%" />
				</td>
			</tr>
			<tr>
				<td class="td1">联系地址：</td>
				<td class="td2"><form:input path="address" maxlength="200"
						cssStyle="width:80%" />
				</td>
			</tr>

			<tr style="display:none">
				<td class="td1">所属部门：</td>
				<td class="td2" colspan="3"><form:hidden path="appDepartmentId" />
					<isperp:treeSelector id="selectParentDepartment"
						onlySelectLeaf="false" displayValueCssStyle="width:300px"
						displayValueCssClass="required" url="app/department/getTree"
						valueControlId="appDepartmentId" displayValue="${deptName}"></isperp:treeSelector>
					<form:hidden path="customerId" /></td>
			</tr>



		</tbody>
	</table>
</form:form>


<isperp:buttonList>
	<button class="submit" onclick="isperp.submitForm();return false;">
		<span class="icon icon-save"></span>提交
	</button>
</isperp:buttonList>
<script type="text/javascript">
	function userNameChange() {
		var id = '${model.id}';
		var name = $("#name").val();
		$.ajax({
			async : false,
			url : "app/user/ifExistsUser?id=" + id + "&name=" + name,
			success : function(data) {
				if (data.success == false) {
					isperp.alert("该用户已存在！");
					$("#name").val("");
				}
			}
		});
	}
</script>

